<%@ page pageEncoding="utf-8" language="java" %>
<%@ include file="/WEB-INF/views/common/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<%@ include file="/WEB-INF/views/common/head.jsp"%>
	<title>后台管理系统 - stoat</title>
	<style type="text/css">
		
	</style>
	
</head>
<body>
	
	<form:form action="${ctx}/sys/role/save" modelAttribute="prpmRole" method="post" class="form form-horizontal" id="form-add">
		<div class="page-container">
			<sys:msg msgObj="${msg}" />
			<form:hidden path="id" />
			
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>角色名：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<form:input path="roleName" placeholder="字符长度3-36" cssClass="input-text" />
				</div>
			</div>
			
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">角色代码：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" name="" id="" placeholder="关闭" disabled="disabled" value="" class="input-text">
				</div>
			</div>
			
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">备注：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<form:textarea path="remark" cssClass="textarea"  placeholder="说点什么...200个字符以内" datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)" />
					<p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
				</div>
			</div>
			
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
					<button class="btn btn-primary radius" type="submit">确定</button>
					<button onclick="st_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
				</div>
			</div>
		</div>
	</form:form>
	
	<%@ include file="/WEB-INF/views/common/footer.jsp"%>
	<script src="${ctxStatic}/lib/jquery/jquery.form.js" type="text/javascript"></script>
	<script src="${ctxStatic}/lib/layer/3.0.1/layer.js" type="text/javascript"></script>
	<script src="${ctxStatic}/lib/icheck/jquery.icheck.min.js" type="text/javascript"></script>
	<script src="${ctxStatic}/lib/jquery.validation/1.14.0/jquery.validate.min.js" type="text/javascript"></script> 
	<script src="${ctxStatic}/lib/jquery.validation/1.14.0/validate-methods.js" type="text/javascript"></script> 
	<script src="${ctxStatic}/lib/jquery.validation/1.14.0/messages_zh.min.js" type="text/javascript"></script> 
	
	<script type="text/javascript">
		$(function(){
			//校验
			$("#form-add").validate({
				rules:{
					roleName:{
						required:true,
						minlength:3,
						maxlength:26
					}
				},
				messages :{
					loginName : "该帐号已经存在或不是有效帐号"
				},
				onkeyup : false,
				focusCleanup : true,
				success : "valid",
				submitHandler : function(form){
					$(form).ajaxSubmit({
						success : function(){
							layer.msg('新增或修改成功');
							setTimeout(function(){
								var index = parent.layer.getFrameIndex(window.name);
								parent.$('.btn-refresh').click();
								parent.layer.close(index);
							}, 1000);
						},
						error : function(){
							layer.msg('新增或修改失败');
						}
					});
				}
			});
		});
		
		function st_close(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
	</script>
</body>
</html>